package cn.tangcent;

import cn.tangcent.rules.*;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by TangMing on 2017/4/9.
 */
public class Sudoku {
    private SudokuExecutor sudokuExecutor;

    public Sudoku(String eles) {
        this(SudokuUtils.string2Sudoku(eles));
    }

    public Sudoku(int[][] elements) {
        SudokuData sudokuData = new SudokuData(elements);
        List<SudokuRule> sudokuRules = new ArrayList<>();
        sudokuRules.add(new EleRule());
        sudokuRules.add(new BlockRule());
        sudokuRules.add(new RowRule());
        sudokuRules.add(new ColumnRule());
        sudokuRules.add(new GeminiRule());
        sudokuExecutor = new SudokuExecutor(sudokuData, sudokuRules);
    }

    public void start() {
        sudokuExecutor.start();
    }

    public int[][] result() {
        return sudokuExecutor.result();
    }
}
